package cn.codingtalk.tacomallinterfaceportal.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.codingtalk.tacomallcommon.vo.ResponseVo;
import cn.codingtalk.tacomallcommon.util.RequestUtil;
import cn.codingtalk.tacomallinterfaceportal.service.MemberService;

@Api("seller user module")
@RestController
@RequestMapping("/portal")
public class MemberController {

    @Autowired
    private MemberService memberService;

    @ApiOperation("seller login")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "requestUtil", value = "request json", dataType = "json"),
    })
    @PostMapping("/memberLogin")
    public String memberLogin(@RequestBody RequestUtil requestUtil) {
        return "hello memberLogin";
    }

    @ApiOperation("find seller by id")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "requestUtil", value = "request json", dataType = "json"),
    })
    @PostMapping("/member")
    public ResponseVo findById(@RequestBody RequestUtil requestUtil) throws Exception {
        int id = requestUtil.getInt("id");
        System.out.println(id);
        return memberService.findById(id);
    }
}
